<template>
  <div class="index">
    <el-container>
      <el-header height="68px">
        <m-header></m-header>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <m-aside></m-aside>
        </el-aside>
        <el-main>
          <div class="main">
            <div class="header-top">
              <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>红包列表</el-breadcrumb-item>
                <el-breadcrumb-item>违规拉新管理</el-breadcrumb-item>
              </el-breadcrumb>
              <h2 class="title">疑似问题用户（拉新）</h2>
            </div>
            <div class="row">
              <el-table
                :data="tableData"
                border
                :cell-style="{'text-align':'center'}"

                :header-cell-style="{
                  'background-color': '#f5f5f5',
                  'color':'#555',
                  'text-align':'center'
                }"
                style="width: 100%">
                <el-table-column
                  prop="nickName"
                  label="昵称">
                  <template slot-scope="scope">
                    <el-button @click="checkClick(scope.row)" type="text" size="small">{{scope.row.nickName}}</el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="registDate"
                  label="注册日期">
                </el-table-column>
                <el-table-column
                  prop="totalDays"
                  label="所有徒弟存活天数">
                </el-table-column>  
                <el-table-column
                  prop="totalCashJournalRows"
                  label="资金明细记录总数">
                </el-table-column>
                <el-table-column
                  prop="avgCashJournalPerDay"
                  label="平均记录数/每天">
                </el-table-column>
                <el-table-column
                  prop="pLCount"
                  label="每单位时间收徒次数">
                </el-table-column>
  
                <el-table-column
                  label="操作"
                  width="300">
                  <template slot-scope="scope">
                    <el-button @click="blacklistClick(scope.row)" type="text" size="small">加入黑名单</el-button>
                    <el-button @click="deleteClick(scope.row)" type="text" size="small">从名单中删除</el-button>
                  </template>
                </el-table-column>
                
              </el-table>
    
            </div>

          </div>
        </el-main>
      </el-container>
      <el-dialog
        :visible.sync="dialogVisible"

        :close-on-click-modal='boole'
        custom-class="diaself"
        center
        top='30vh'
        width="28%">
        <el-form ref="form" :model="form" label-width="80px" class="text-style">
          <el-form-item label="昵称">
            <span v-text="form.name"></span>
          </el-form-item>
          <el-form-item label="userid">

            <span v-text="form.userid"></span>
          </el-form-item>
          <el-form-item label="等级">
            <el-select v-model="form.region" >
              <el-option label="3.师傅冻结,徒弟冻结" value=""></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer" style="text-align:center">
          <el-button type="primary" @click="submit" >提 交</el-button>
        </span>
      </el-dialog>
    </el-container>
  </div>
</template>
<script>
import { getCookie,timeChange,getQueryString } from "./until/index";
function init(){
  this.$ajax.get("admGetUserExcepLaxiList.ashx?uid="+getCookie("userid") +"&token=" +getCookie("token"))
      .then(res => {
        
        if (res.data.code === "200") {
          var data = res.data.data;
          this.tableData = data.userList;

        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
function removeException(row){//移除黑名单
  this.$ajax.get("admRemoveExceptionLaxinUser.ashx?uid="+getCookie("userid") +"&token=" +getCookie("token")+'&exUserID='+row)
      .then(res => {
        if (res.data.code === "200") {
          this.$message({
            type: 'success',
            message: res.data.msg,
            onClose:()=>{

              init.call(this)
            }
          });

        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
function pushToBlack (row,count){ //加入黑名单
  this.$ajax.get("admAdmPushToBlackList.ashx?uid="+getCookie("userid") +"&token=" +getCookie("token")+'&exUserID='+row+'&fxLevel='+count)
      .then(res => {
        if (res.data.code === "200") {
          
          this.$message({
            type: 'success',
            message: res.data.msg,
            onClose:()=>{
              init.call(this)
              this.dialogVisible = false
            }
          });
        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}

export default {
  data() {
    return {
      dialogVisible: false,
      boole:false,
      tableData: [],
      type:'',
      form:{
        name:'',
        userid:'',
        region:''
      }

    };
  },
  created() {
    
    
    init.call(this)
  },
  methods: {
    
    blacklistClick(row){ //加入黑名单
      
      this.dialogVisible = true
      this.form.name = row.nickName
      this.form.userid = row.userID
      
    },
    deleteClick(row){//从列表中删除
      
      this.$confirm('确定从名单中删除 ?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          
          removeException.call(this,row.userID)
           
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消操作'
          });          
        });

      
    },
    submit(){

      if(this.form.region == ''){
        this.type = 3
      }else{
        this.type = this.form.region
      }

      pushToBlack.call(this,this.form.userid,this.type)
    },
    checkClick(row){
      let routeUrl = this.$router.resolve({ path: '/index', query: { userID: row.userID }});
      window.open(routeUrl .href, '_blank');
    },
    
  }
};
</script>
<style scoped>
.index {
  overflow: hidden;
}
.water{margin-right: 20px;display: inline-block}
.waterTime{font-size: 14px;color: #606266;padding: 0 12px 0 0;box-sizing: border-box;}
.el-header {
  background-color: #3a4759;
  color: #fff;
}
.el-aside {
  background-color: #485668;
  color: #333;
  text-align: center;
  line-height: 200px;
  overflow: hidden;
}
.el-main {
  background-color: #f0f2f5;
  color: #333;
  text-align: center;
  height: 100%;
  min-height: 740px
}

.text-style .el-form-item__content span,.el-select{margin-left: 25px}
.diaself .el-dialog__header{padding:0 !important}
.el-dialog--center .el-dialog__body {
    padding: 0;
}
.el-form-item{margin-bottom: 10px}
.header-top{
  margin: -20px -20px 20px;
  padding: 15px 20px;
  background: #fff;
  
}
.header-top .title{
  margin:15px 0 0;
  font-weight: 600;
  text-align: center;
  font-size: 20px;
}
.row{
  background: #fff;
  padding: 20px 30px;
  text-align: left
}
.block {
  padding: 20px;
}
.message{
  margin-top: 20px;
}
</style>
  